package linz

/**
 * 枚举类
 */
enum class Week{
    星期一,
    星期二,
    星期三,
    星期四,
    星期五,
    星期六,
    星期日,
}


data class Status(val status: Int, val msg: String, val colorId: Int)

enum class StatusEnum(private var status: Status){
    REFUSE(Status(1,"拒绝",1)),
    CONFIRM(Status(2,"同意",2));

    fun show() = "status：${status.status} msg:${status.msg} colorId: ${status.colorId}"

    fun updateValue(status: Status){
        this.status = status
    }
}


enum class Exam{
    HIGH,
    MIDDLE,
    LOW
}

private class Student_(private val exam:Exam){
    fun show() =
        when(exam){
            Exam.HIGH -> "良好AA"
            Exam.LOW -> "不及格"
            Exam.MIDDLE -> "中等"
        }
}


/**
 * todo 重点
 * 密封类，成员，必须有类型 并且继承本类
 */
sealed class SealExams {
    object High: SealExams()
    object Middle: SealExams()
    object Low: SealExams()
    class Best(val name:String) :SealExams()
}

class SealStudent(private val sealExams: SealExams){
    fun show() =
        when(sealExams){
            is SealExams.High -> "良好AA"
            is SealExams.Low -> "不及格"
            is SealExams.Middle -> "中等"
            is SealExams.Best -> "优秀 ${this.sealExams.name}"
        }
}

fun main() {
    println(Week.星期一)

    println(Week.星期五 is Week)

    println(StatusEnum.REFUSE.show())

    println(Student_(Exam.LOW).show())

    // 密封类做枚举

    println(SealStudent(SealExams.High).show())
    println(SealStudent(SealExams.Best("小Null")).show())

    println(SealExams.High === SealExams.High) // true  object 是单例
    println(SealExams.Best("小名") === SealExams.Best("小名")) // false 对象

}